<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class Image
 *
 * @property int $id
 * @property int|null $user_id
 * @property int|null $record_user_id
 * @property int|null $order_id
 * @property int|null $worker_id
 * @property int|null $record_worker_id
 * @property int|null $bank_card_id
 * @property string|null $title
 * @property string|null $url
 * @property string|null $img_path
 * @property int|null $img_type
 * @property int|null $weight
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 *
 * @property BankCard|null $bank_card
 * @property Order|null $order
 * @property User|null $user
 * @property Worker|null $worker
 * @property Collection|MassageChangeRecord[] $massage_change_records
 * @property Collection|OaRecord[] $oa_records
 *
 * @package App\Models
 */
class Image extends Model
{
	protected $table = 'image';

	protected $casts = [
		'user_id' => 'int',
		'record_user_id' => 'int',
		'order_id' => 'int',
		'worker_id' => 'int',
		'record_worker_id' => 'int',
		'bank_card_id' => 'int',
		'img_type' => 'int',
		'weight' => 'int'
	];

	protected $fillable = [
		'user_id',
		'record_user_id',
		'order_id',
		'worker_id',
		'record_worker_id',
		'bank_card_id',
		'title',
		'url',
		'img_path',
		'img_type',
		'weight'
	];

	public function bank_card()
	{
		return $this->belongsTo(BankCard::class);
	}

	public function order()
	{
		return $this->belongsTo(Order::class);
	}

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function worker()
    {
        return $this->belongsTo(Worker::class);
    }
    public function record_user()
    {
        return $this->belongsTo(User::class, 'record_user_id');
    }

    public function record_worker()
    {
        return $this->belongsTo(Worker::class, 'record_worker_id');
    }
}
